package iterator_pattern.exercise.exercise1;

/**
 * 技术部迭代器
 * @author ricejson
 */
public class TechDepartmentIterator implements Iterator {
    private TechDepartment department;
    private int current = 0;

    public TechDepartmentIterator(TechDepartment department) {
        this.department = department;
    }

    @Override
    public Object first() {
        return department.get(0);
    }

    @Override
    public boolean isDone() {
        return current >= department.size();
    }

    @Override
    public Object next() {
        current++;
        if (current < department.size()) {
            return department.get(current);
        }
        return null;
    }

    @Override
    public Object currentItem() {
        return department.get(current);
    }
}
